<?php
if( !defined( 'MEDIAWIKI' ) )
	die(-1);

global $IP;
require_once('includes/SkinTemplate.php');

/**
 * Inherit main code from SkinTemplate, set the CSS and template filter.
 * @package MediaWiki
 * @subpackage Skins
 */
class Skinsoundshare extends SkinTemplate {
	function initPage( &$out ) {
		SkinTemplate::initPage( $out );
		$this->skinname  = 'soundshare';
		$this->stylename = 'soundshare';
		$this->template  = 'SoundshareTemplate';
	}
	
	function setupSkinUserCss( OutputPage $out ) {
		

		parent::setupSkinUserCss( $out );
		
		//$out->addStyle( 'soundshare/rtl.css', 'screen', '', 'rtl' );
	}	
}

class SoundshareTemplate extends QuickTemplate {

	public function ShowSearchForm() {?>


<form class="asholder" name="searchform" action="/search/<?php wfUrlencode($this->text('search'))?>" id="search" method="post">
			<div id="searchDiv">

                            <div class="index_files_claim"><small>indexing <?=TotalFilesNum();?> p2p links today</small></div>
                            
                            <span id="searchBox">
				<input autocomplete="off" name="search" id="searchText" type="text" onchange="parentNode.parentNode.parentNode.action='/search/'+value.replace(' ', '+')" onkeyup="parentNode.parentNode.parentNode.action='/search/'+value.replace(' ', '+')"
				<?php if($this->haveMsg('accesskey-search')) {?>accesskey="<?php $this->msg('accesskey-search') ?>"
			<?php }
			$searched = $this->data['search'];
		        if( isset( $searched ) ) echo " value=\"".strtr(htmlspecialchars($searched, ENT_QUOTES), '+', ' ')."\""; ?> /></span>
				<input type="submit" name="fulltext" class="searchButton" value="<?php $this->msg('search') ?>" />
			</div>
		</form>
	<?php }

	/**
	 * Template filter callback for soundshare skin.
	 * Takes an associative array of data set from a SkinTemplate-based
	 * class, and a wrapper for MediaWiki's localization database, and
	 * outputs a formatted page.
	 *
	 * @access private
	 */
	function execute() {
	  	global $wgRequest,$wgOut , $wgLang,$wgCookieDomain,$wgTitle,$wgUser;
		$this->skin = $skin = $this->data['skin'];
		$action = $wgRequest->getText( 'action' );


                //this code aims to assure if enter by domain without setlang and the lang its right
                $urlpartial =  explode('.', $wgTitle->getFullURL(), 2);

                //fix for www.
                if( $urlpartial[0]  == 'http://www'  ){
                    header("HTTP/1.0 301 Moved Permanently");
                    header( 'Location: http://'.$wgLang->getCode().'.'.$urlpartial[1]);
                    exit;

                }
                //fix for soundshare.com without subdomain
                 if( $urlpartial[0] == 'http://soundshare'  ){
                    header("HTTP/1.0 301 Moved Permanently");
                    header( 'Location: http://'.$wgLang->getCode().'.soundshare.'.$urlpartial[1]);
                    exit;

                }



                //if the user is not logged in , goto user login page
                $value = $wgRequest->getText( 'title' );
                $values = explode(":", $value);

                //First check if the type of content (url) is the kind to render this module (Main_Page)
                //if (!$wgUser->loggedin) {
                if ($values[0] == 'Category' && $values[1] == 'All' && !$wgUser->isLoggedIn()) {
                     header( 'Location: /s/UserLogin?type=signup');
                }


		// Suppress warnings to prevent notices about missing indexes in $this->data
		wfSuppressWarnings();

		?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?=$this->data['userlang']?>">
<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Language" content="<?=$this->data['userlang']?>" />
		<meta name="googlebot" content="index, follow" />
		<meta name="verify-v1" content="FkCh89T34CnO4j/IsA48aMUkMfevf1PgyO82slCVqXo=" />
		<!-- TODO delete this tag noarchive when release public--->
		<meta name="googlebot" content="noarchive" />
		
		<?php
		if( $this->data['thispage'] == 'Main_Page') {
				$wgOut->addMeta('description', 'Soundshare is the free social web where you could share your knowledge about music, artists, songs, p2p mp3s links');
				$wgOut->addMeta('keywords', 'soundshare, p2p, mp3, music, free, artist, song, release');
				$wgOut->addMeta('title', 'Soundshare music, artists, mp3');
		}

		if($this->data['thispage'] !== 'Special:MP3' || $this->data['thispage'] !== 'Main_Page') {
			$wgOut->addMeta('description', $this->data['pagetitle']);
			$wgOut->addMeta('keywords', 'soundshare, p2p, mp3, music, free, artist, song, release');
			$wgOut->addMeta('title', $this->data['pagetitle']);
		}
		?>

		<?php

		$wgOut->addMeta( 'robots', 'index,follow' );
		$this->html('headlinks') ?>
		<link rel="stylesheet" href="<?=$wgScriptPath; ?>/skins/common/shared.css?<?php echo $GLOBALS['wgStyleVersion'] ?>" type="text/css" media="screen" />
		<link rel="stylesheet" href="<?=$wgScriptPath; ?>/skins/soundshare/css/main.css?<?php echo $GLOBALS['wgStyleVersion'] ?>" type="text/css" media="screen" />
		<link rel='stylesheet' type='text/css' href="<?=$wgScriptPath; ?>/extensions/SocialProfile/UserProfile/UserProfile.css?<?php echo $GLOBALS['wgStyleVersion'] ?>"/>
		
		<link rel="shortcut icon" href="/favicon.ico" />
		<title><?php if($this->data['thispage'] == 'Main_Page') { echo 'Soundshare, download free music mp3'; ?>
	<?php } else $this->HTML('pagetitle'); ?></title>

		
		<?php print Skin::makeGlobalVariablesScript( $this->data ); ?>
		<script type="text/javascript" src="<?=$wgScriptPath; ?>/skins/common/wikibits.js"><!-- wikibits js --></script>
		
		<!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js?<?php echo $GLOBALS['wgStyleVersion'] ?>"></script>
  		<meta http-equiv="imagetoolbar" content="no" /><![endif]-->


		<!-- Head Scripts -->
		<?php $this->html('headscripts') ?>


</head>

    

<body<?php if($this->data['body_ondblclick']) { ?> ondblclick="<?php $this->text('body_ondblclick') ?>"<?php } ?>
<?php if($this->data['body_onload']) { ?> onload="<?php $this->text('body_onload') ?>"<?php } ?>
 class="mediawiki <?php $this->text('dir') ?> <?php $this->text('pageclass') ?> <?php $this->text('skinnameclass') ?>">

<div id="container" class="wrap">
<span id="languageselector1">
<a href="javascript:;" onmousedown="if(document.getElementById('language-selector').style.display == 'none'){ document.getElementById('language-selector').style.display = 'block'; }else{ document.getElementById('language-selector').style.display = 'none'; }">
<img border="0" src="/skins/soundshare/flags/<?=$this->data['userlang']?>.gif" alt="<?=$this->data['userlang']?>" /> </a>
</span>


<?php
//***********************DEBUG OBJECT TRACES

//var_dump($wgLang->getCode());
//var_dump($this);
//var_dump($wgCookieDomain);
 //var_dump($wgTitle->getFullURL());
?>



	<?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>

	<div id="header">
		<div id="loginBox">
	 <?php
	 global $wgUser;
	 if( $wgUser->isLoggedIn() ) {

                   $avatar = new wAvatar( $wgUser->mId, 's' );

		  echo '
                    <a  href="'.htmlspecialchars($this->data['personal_urls']['userpage']['href']).'">'.htmlspecialchars($this->data['username']).'</a>
                    <a href="/users/'.htmlspecialchars($this->data['username']).'">'.$avatar->getAvatarURL().'</a>
                    ';
		  echo ' | <a rel="nofollow" href="'.htmlspecialchars($this->data['personal_urls']['logout']['href']).'">'.htmlspecialchars($this->data['personal_urls']['logout']['text']).'</a>';

	 } else {
		  echo '<a rel="nofollow" href="'.$this->data['wgScript'].'?title=Special:UserLogin&returnto='.htmlspecialchars($this->data['thispage']).'">login</a>';
		  echo ' | <a rel="nofollow" href="'.$this->data['wgScript'].'?title=Special:UserLogin&type=signup&returnto='.htmlspecialchars($this->data['thispage']).'">sign up</a>';

	}


	?>
	</div>
	<!-- end of login-box -->


	
	<h4><a href="/" title="soundshare.com"><?='soundshare.com' ?></a></h4>

	<?=$this->ShowSearchForm(); ?>

	<?
	$special_download = SpecialPage::getTitleFor( 'Download' );
	$special_top_artists = SpecialPage::getTitleFor( 'TopArtists' );
	$special_top_albums = SpecialPage::getTitleFor( 'TopAlbums' );
	$special_top_songs = SpecialPage::getTitleFor( 'TopSongs' );
	$special_browse_tags = SpecialPage::getTitleFor( 'BrowseTags' );
	$special_random_song = SpecialPage::getTitleFor( 'Random/Song' );
        $special_random_song = '/s/Random/Song' ;

	?>


	<ul>
			<li><a href="<?=$special_download->escapeFullURL()?>"><?=wfMsg( 'special_download' )?></a></li>
		|
			<li><a href="/music/<?php $this->html('artistDay')?>"><?=wfMsg( 'artist_of_the_day' )?></a></li>
		|
			<li><a href="<?=$special_top_artists->escapeFullURL()?>"><?=wfMsg( 'special_top_artists' )?></a></li>
		|
			<li><a href="<?=$special_top_albums->escapeFullURL()?>"><?=wfMsg( 'special_top_albums' )?></a></li>
		|
			<li><a href="<?=$special_top_songs->escapeFullURL()?>"><?=wfMsg( 'special_top_songs' )?></a></li>
		|
			<li><a href="<?=$special_browse_tags->escapeFullURL()?>"><?=wfMsg( 'special_browse_tags' )?></a></li>

		</ul>



</div><!-- end of header -->

<?php $this->html('cloud') ?>

<div id="language-selector" class="language-selector" style="display:none">

	<div class="picker-top">
			<?=wfMsg('Select your language:'); ?>
	</div>
	<br />

	<div class="flag-bucket">

	
								<div class="flag-div">
									<a href="<?='http://es.'.$urlpartial[1]; ?>">
										<img src="/skins/soundshare/flags/es.gif" border="0" alt="Español" /> Español
									</a>
								</div>

								<div class="flag-div">
									<a href="<?='http://en.'.$urlpartial[1]; ?>">
										<img src="/skins/soundshare/flags/en.gif" border="0" alt="English" /> English
									</a>
								</div>
								<div class="flag-div">
									<a href="<?='http://de.'.$urlpartial[1]; ?>">
										<img src="/skins/soundshare/flags/de.gif" border="0" alt="Deutsch" /> Deutsch
									</a>
								</div>
</div>
<div class="flag-bucket">
								<div class="flag-div">
									<a href="<?='http://fr.'.$urlpartial[1]; ?>">
										<img src="/skins/soundshare/flags/fr.gif" border="0" alt="Française" /> Française
									</a>
								</div>
								<div class="flag-div">
									<a href="<?='http://pt.'.$urlpartial[1]; ?>">
										<img src="/skins/soundshare/flags/pt.gif" border="0" alt="Portugues" /> Portugues
									</a>
								</div>
								<div class="flag-div">
									<a href="<?='http://it.'.$urlpartial[1]; ?>">
										<img src="/skins/soundshare/flags/it.gif" border="0" alt="Italiano" /> Italiano
									</a>
								</div>

	</div>

</div><!-- end of language-selector -->



	<div id="side">
		<ul id="nav"><?php $this->html('genres') ?></ul>
	</div>
	<!-- end of side -->


	<!-- start content -->
	<div id="mainContent" >
		<?php if($this->data['undelete']) { ?><div id="contentSub"><?php $this->html('undelete') ?></div><?php } ?>
		<?php if($this->data['newtalk'] ) { ?><div class="usermessage"><?php $this->html('newtalk')  ?></div><?php } ?>


	<div id="bocata">		
			
		<dl>
  		<dt><img alt="" src="/skins/soundshare/hautd.gif" id="bocatadroitehaut" /></dt>
	     	<dd id="bocatapiquito"> <img alt="" src="/skins/soundshare/piquito_bocata.gif" /></dd>
	     	<dd class="nofile-download" />
			
			<?$this->html('ilikethis');?>
			<?php if ($this->data['type']) {?> <div id='type'><?php $this->html('type') ?></div> <? } ?>


		<!-- start p-cactions -->
		<div id="p-cactions" class="portlet">
			<h5><?php $this->msg('views') ?></h5>
		</div>
	
		<?=$this->html('bocata');?>

		<?php if($this->data['catlinks']) { ?><div id="catlinks"><?php $this->html('catlinks') ?></div><?php } ?>

		<dd id="bocatabas"><img alt="" src="/skins/soundshare/basd.gif" id="bocatadroitebas"/></dd>
		</dl>

		
		</div>
		<!-- end bocata -->
		
		<div id="no-bocata">
			<?php $this->html('no-bocata') ?>
		</div>
		
	</div>


	<!-- end content -->
	</div>
	<!-- end of maincontent -->


<!-- end of container -->

<div id="footer">

		<ul class="links">
			<?php if($this->data['about'     ]) { ?><?php strtolower($this->html('about')) ?><?php } ?>
			<?php if($this->data['disclaimer']) { ?><?php strtolower($this->html('disclaimer')) ?><?php } ?>
			<?php if($this->data['privacy']) { ?><?php strtolower($this->html('privacy')) ?><?php } ?>
			<a href="http://code.google.com/p/soundshare/" ><?=wfMsg('Developers'); ?></a>
		</ul>

<div class="firma">
    <div id="f-list">

			<?php if(($this->data['lastmod'   ]) and  ($this->data['thispage'] != 'Main_Page')) { ?><span id="f-lastmod"><?php    $this->html('lastmod')    ?></span><?php } ?>
			<?php if(($this->data['viewcount' ]) and  ($this->data['thispage'] != 'Main_Page')){ ?><span id="f-viewcount"><?php  $this->html('viewcount')  ?> </span><?php } ?></div>


<div class="logos">
			<a href="http://fundacioncopyleft.org/en">
			<img alt="fundacion copyleft" src="<?php echo htmlspecialchars($this->data['serverurl']).'/skins/soundshare/fundacion-copyleft-07b.gif' ?>"/> </a>
		  <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/es/deed.en"><img alt="Creative Commons License"  src="<?php $this->text('stylepath') ?>/soundshare/cc88x31.png" /></a>
		</div>
	  Content of this website under Creative Commons license.
</div>

</div><!-- end of footer -->



		
<script type="text/javascript" src="<?=$wgScriptPath; ?>/skins/common/common.js"></script>
<script type="text/javascript" src="<?=$wgScriptPath; ?>/skins/common/ajax.js"></script>
<script type="text/javascript" src="<?=$wgScriptPath; ?>/skins/soundshare/ilikethis.js"></script>
<script type="text/javascript" src="<?=$wgScriptPath; ?>/skins/common/rounded_corners.inc.js"></script>
<script type="text/javascript" src="<?=$wgScriptPath; ?>/skins/soundshare/bsn.AutoSuggest_2.1.3.js"></script>





<script type="text/JavaScript">
	                    window.onload = function() {
	                    settings = {
	                    tl: { radius: 45 },
	                    tr: { radius: 45 },
	                    bl: { radius: 45 },
	                    br: { radius: 45 },
	                    antiAlias: true,
	                    autoPad: true
	                 }
	      var myBoxObject = new curvyCorners(settings, "rounded");
	      myBoxObject.applyCornersToAll();
	  }
</script>

<script type="text/javascript">
   var options = {
	script: "/ss_searchSuggest.php?",
        varname: "term",
        shownoresults: false,
        minchars: 1,
        delay:50,
        offsety: 0,
        timeout: 10000,
	maxresults: 5
    };
    var as = new bsn.AutoSuggest('searchText', options);
</script>

<!-- google analytics -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-808946-18");
pageTracker._setDomainName(".soundshare.com");
pageTracker._trackPageview();
} catch(err) {}</script>
<!-- end of google analytics -->


<?php $this->html('bottomscripts'); /* JS call to runBodyOnloadHook */ ?>
<?php $this->html('reporttime') ?>
</body>
</html>

<?php
	}
}
?>
